package com.yl.auth.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.entity.Fangjian;
import com.yl.auth.model.entity.Chuangwei;
import com.yl.auth.model.entity.Cwgenghuan;
import com.yl.auth.model.entity.Laoren;
import com.yl.auth.model.vo.CwgenghuanVo;
import com.yl.auth.model.vo.WeijiVo;
import com.yl.auth.service.CwgenghuanService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ln
 * @since 2023-06-19
 */
@Api(tags = "养老护理-床位更换")
@RestController
@RequestMapping("/admin/cwgenghuan")
public class CwgenghuanController {
    @Resource
    private CwgenghuanService cwgenghuanService;
    @GetMapping("/getcwgenghuan/{page}/{limit}")
    @ApiOperation(value = "获取全部床位更换信息")
    public Result getcwgenghuan(@PathVariable @ApiParam("当前页") Integer page, @PathVariable @ApiParam("总条数") Integer limit, @ApiParam("老人姓名") String lrname, @ApiParam("身份证号") String idnumber, @ApiParam("性别") String gender, @ApiParam("状态") Integer zhuangtai){
        Page<CwgenghuanVo> iPage = new Page<>(page,limit);
        Page<CwgenghuanVo> pageVo = cwgenghuanService.getPageVo(iPage, lrname, idnumber, gender, zhuangtai);
        return Result.ok(pageVo);
    }
    @PostMapping("/addcwgenghuan")
    @ApiOperation(value = "添加床位更换信息")
    public Result addcwgenghuan(@RequestBody @ApiParam("床位更换实体类") Cwgenghuan cwgenghuan){
        cwgenghuanService.save(cwgenghuan);
         return Result.ok();
    }
    @GetMapping("/getcwgenghuans/{id}")
    @ApiOperation(value = "根据Id查询老人")
    public Result getcwgenghuans(@PathVariable @ApiParam("床位更换id")Integer id){
        CwgenghuanVo cwgenghuanVo = cwgenghuanService.getcwgenghuan(id);
        return Result.ok(cwgenghuanVo);
    }
    @GetMapping("/getById/{id}")
    @ApiOperation(value = "根据Id查询信息")
    public Result getById(@PathVariable @ApiParam("床位更换id")Integer id){
        CwgenghuanVo cwgenghuanVo = cwgenghuanService.getBycwId(id);
        return Result.ok(cwgenghuanVo);
    }
    @PutMapping("/updatecwgenghuan")
    @ApiOperation(value = "编辑床位更换信息")
    public Result updatecwgenghuan(@RequestBody Cwgenghuan cwgenghuan){
        cwgenghuan.setZhuangtai(3);
        cwgenghuanService.updateById(cwgenghuan);
        return Result.ok();
    }
    @ApiOperation(value = "查询所有的老人信息")
    @GetMapping("/findAlllr")
    public Result findAll() {
        List<Laoren> list = cwgenghuanService.lists();
        return Result.ok(list);
    }
//    @GetMapping("/getByIdlrgenghuan/{id}")
//    @ApiOperation(value = "根据Id查询老人和床位更换信息")
//    public Result getByIdlrgenghuan(@PathVariable Integer id){
//        CwgenghuanVo cwgenghuanVo = cwgenghuanService.getByIdlrgenghuan(id);
//        return Result.ok(cwgenghuanVo);
//    }
    @GetMapping("/getBypricefj")
    @ApiOperation(value = "查询全部房间信息")
    public Result getBypricefj(){
        List<CwgenghuanVo> cwgenghuanVo = cwgenghuanService.getBypricefj();
        return Result.ok(cwgenghuanVo);
    }
    @GetMapping("/getfindAll/{id}")
    @ApiOperation(value = "获取全部状态为未住入床位的信息")
    public Result getfindAll(@PathVariable @ApiParam("房间id")Long id) {
        List<Chuangwei> getfindAll = cwgenghuanService.getfindsAll(id);
        return Result.ok(getfindAll);
    }
    @GetMapping("/gethg")
    @ApiOperation(value = "获取全部护工")
    public Result gethg(){
        List<CwgenghuanVo> pageVo = cwgenghuanService.gethg();
        return Result.ok(pageVo);
    }
}

